﻿using _2308NA.Model;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2308NA.DAL
{
    public class RolesDal
    {
        SQLHelp help = new SQLHelp();

        public List<Roles> GetRoles() {
            List<Roles> list = new List<Roles>();

            string sql = @"select * from Roles";
            SqlDataReader sdr = help.ExecuteReader(sql,null);
            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    list.Add(new Roles() {
                        RoleID= (int)sdr["roleID"],
                        DeptID = (int)sdr["deptID"],
                        RoleName = sdr["roleName"].ToString(),
                        Remark = sdr["remark"].ToString(),
                        Type = (int)sdr["type"]
                    });
                }
            }
            sdr.Close();

            return list;
        }
    }
}
